<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<h:head>
	</h:head>

	<body>
		<p:tabView id="tabViewMidia">

			<p:tab id="tabMidia" title="CadastroDeMidia">
				<p:messages id="messages" />
				<h:message for="frmMidia" />
				<h:form id="frmMidia">



					<h:panelGrid id="tblMidias" columns="2" cellpadding="3">


						<h:outputText value="Selecione a Obra: " />
						<p:selectOneMenu value="#{midiaBean.obraId}" effect="fade"
							var="obra">
							<f:selectItems value="#{obraBean.obras}" var="o"
								itemValue="#{o.id}" />

							<p:column>  
	                #{o.titulo}
	            </p:column>
						</p:selectOneMenu>






						<h:outputText value="Tipo: " />
						<p:selectOneMenu value="#{midiaBean.tipoDeMidia}">
							<f:selectItem itemLabel="DVD" itemValue="DVD" />
							<f:selectItem itemLabel="Blu-ray" itemValue="BD" />
						</p:selectOneMenu>




						<h:outputText value="Quantidade: " />
						<p:inputText id="quantidade" value="#{midiaBean.quantidade}" />
					</h:panelGrid>

					<h:commandButton value="Cadastrar" update="tblMidias" id="ajax"
						action="#{midiaBean.adicionaMidia()}" />
				</h:form>
			</p:tab>

			<p:tab id="tab2Midia" title="ListadeMidias" >
				<h:form id="frmLista">
					<p:dataTable id="tblMidia" var="m" value="#{midiaBean.midias}"
						editable="true">
						
						
						<p:column>
							<p:graphicImage
								value= "#{m.obra.imagem}"
								width="80" height="100" />
						</p:column>



						<p:column id="tituloDaObra" filterBy="#{m.obra.titulo}"
							headerText="Título">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{m.obra.titulo}" />
								</f:facet>
								<f:facet name="input">
									<h:inputText value="#{m.obra.titulo}" required="true" />
								</f:facet>
							</p:cellEditor>
						</p:column>



						<p:column id="descricaoObra" filterBy="#{m.obra.descricao}"
							headerText="Descrição">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{m.obra.descricao}" />
								</f:facet>
								<f:facet name="input">
									<h:inputText value="#{m.obra.descricao}" required="true" />
								</f:facet>
							</p:cellEditor>
						</p:column>



						<p:column id="RotuloObra" filterBy="#{m.obra.rotulo}"
							headerText="Rótulo">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{m.obra.rotulo}" />
								</f:facet>
								<f:facet name="input">
									<h:inputText value="#{m.obra.rotulo}" required="true" />
								</f:facet>
							</p:cellEditor>
						</p:column>



						<p:column id="tipoMidia" filterBy="#{m.tipoMidia}"
							headerText="Tipo">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{m.tipoMidia}" />
								</f:facet>
								<f:facet name="input">
									<h:inputText value="#{m.tipoMidia}" required="true" />
								</f:facet>
							</p:cellEditor>
						</p:column>



						<p:column id="quantidadeDeMidias" filterBy="#{m.qtde}"
							headerText="Quantidade">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="#{m.qtde}" />
								</f:facet>
								<f:facet name="input">
									<h:inputText value="#{m.qtde}" required="true" />
								</f:facet>
							</p:cellEditor>
						</p:column>



						<p:column id="preco" headerText="Valor da Locação">
							<p:cellEditor>
								<f:facet name="output">
									<h:outputText value="R$ #{midiaBean.getValorLocacao(m)}" />
								</f:facet>
								<f:facet name="input">
									<h:inputText value="R$ #{midiaBean.getValorLocacao(m)}"
										required="true" />
								</f:facet>
							</p:cellEditor>
						</p:column>
						
						
						

						<p:column headerText="Alterar">
							<p:rowEditor></p:rowEditor>
						</p:column>




						<p:column headerText="Excluir">
							<f:facet name="header"></f:facet>
							<p:commandButton action="#{midiaBean.excluir}"
								icon="ui-icon-trash" update="tblMidia">
								<f:param name="id" value="#{m.id}" />
							</p:commandButton>
						</p:column>

					</p:dataTable>


				</h:form>
			</p:tab>
		</p:tabView>
	</body>
</ui:composition>